function onClickLogin(eventObject) {
    $('#usernameField').parent().removeClass('has-error has-feedback').find('span').remove();
    $('#passwordField').parent().removeClass('has-error has-feedback').find('span').remove();
    
    var username = $('#usernameField').val();
    if (!username) {
        $('#usernameField').parent().addClass('has-error has-feedback');
        $('<span class="help-block"><span class="glyphicon glyphicon-remove"></span> Username must have 1-70 characters!</span>').insertAfter('#usernameField');
        return;
    }
    if (username.length > 70) {
        $('#usernameField').parent().addClass('has-error has-feedback');
        $('<span class="help-block"><span class="glyphicon glyphicon-remove"></span> Username must have 1-70 characters!</span>').insertAfter('#usernameField');
        return;
    }
    
    var password = $('#passwordField').val();
    if (!password) {
        $('#passwordField').parent().addClass('has-error has-feedback');
        $('<span class="help-block"><span class="glyphicon glyphicon-remove"></span> Password must have 1-70 characters!</span>').insertAfter('#passwordField');
        return;
    }
    if (password.length > 70) {
        $('#passwordField').parent().addClass('has-error has-feedback');
        $('<span class="help-block"><span class="glyphicon glyphicon-remove"></span> Password must have 1-70 characters!</span>').insertAfter('#passwordField');
        return;
    }
    
    sendLogin(username, password, function (data) {
        if(data["success"] === true) {
            window.location = '/Trabalho_PD/homepage.html';
        }
    });
}
